package com.changgou.search.listener;


import com.changgou.search.config.RabbitMQConfig;
import com.changgou.search.service.ESManagerService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GoodsUpListener {

	@Autowired
	ESManagerService esManagerService;

	//定义MQ的监听方法
	@RabbitListener(queues = RabbitMQConfig.SEARCH_ADD_QUEUE)
	public void receiveMessage(String spuId){
		System.out.println("接受到的消息是："+spuId);

		//将消息传入es业务层，最终导入ES
		esManagerService.importDataBySpuId(spuId);
	}
}
